<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div {
        position: relative;
        width: 450px;
        margin: 300px auto;
        border-bottom: 1px solid silver;
    }

    input {
        width: 380px;
        height: 30px;
        border: 0;
        /* 去掉框框 */
        outline: none;
    }

    img {
        position: absolute;
        right: 10px;
        top: 5px;
        width: 20px;
        height: 20px;
    }
</style>

<body>
    <div>
        <label for="" id="img">
            <img src="/跟着狂神/img/不可见.png" alt="">
            <input type="password" id="paw">
        </label>
    </div>
    <script>
        var img = document.querySelector('img')
        var paw = document.getElementById('paw')
        var falg = false;
        img.onclick = function () {
            if (falg == false) {
                paw.type = 'text';
                img.src = '/跟着狂神/img/眼睛.png'
                falg = true;
            } else {
                paw.type = 'password';
                img.src = '/跟着狂神/img/不可见.png'

                falg = false;
            }
        }
    </script>
</body>

</html>